﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="openCard.aspx.cs" Inherits="WebSite.admin.product.openCard" %>
<%@ Register assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>阳澄湖牌 </title>
    <link href="../css/skin.css" rel="stylesheet" type="text/css" />
           <script type="text/javascript" src="../js/main.js"></script>
     <script language="javascript" type="text/javascript" src="/My97DatePicker/WdatePicker.js"    ></script>

	<script type="text/javascript" language="javascript">
	    function CheckSelect(del, str) {
	        var rt = true;
	        var num = 0;
	        var boxorder = 0;
	        var objCheckBox;
	        for (var i = 0; i < form1.length; i++) {
	            ///alert(form1.elements[i].type);
	            if (form1.elements[i].type == "checkbox") {
	                boxorder++;
	                objCheckBox = form1.elements[i];
	                ///alert(objCheckBox.checked);
	                if (objCheckBox.checked) {
	                    if (boxorder > 1) {
	                        //如果是第一个CheckBox，是用来全选全消的，这个不算，不用自加
	                        num++;
	                    }
	                }
	            }
	        }
	        ///alert(num);
	        if (!del) {
	            if (num > 1) {
	                alert("此操作不允许选择多个事件");
	                rt = false;
	            }
	        }
	        if (str == 'del') {
	            if (num == 0) {
	                alert("你没有选择要开卡的记录");
	                rt = false
	            } else { return confirm('你确定要对选种的卡片开卡吗?'); }
	            ///alert(rt);
	        }
	        else {
	            if (str == 'update') {
	                if (num == 0) {
	                    alert("你没有选择要更新的信息");
	                    rt = false
	                } else { return confirm('你确定要更新这些信息吗?'); }
	                ///alert(rt);
	            }
	        }
	        return rt;
	    }

	    function CheckSelectUpdate(del, str,message) {
	        var rt = true;
	        var num = 0;
	        var boxorder = 0;
	        var objCheckBox;
	        for (var i = 0; i < form1.length; i++) {
	            ///alert(form1.elements[i].type);
	            if (form1.elements[i].type == "checkbox") {
	                boxorder++;
	                objCheckBox = form1.elements[i];
	                ///alert(objCheckBox.checked);
	                if (objCheckBox.checked) {
	                    if (boxorder > 1) {
	                        //如果是第一个CheckBox，是用来全选全消的，这个不算，不用自加
	                        num++;
	                    }
	                }
	            }
	        }
	      
	            if (str == 'update') {
	                if (num == 0) {
	                    alert("你没有选择要更新的信息");
	                    rt = false
	                } else { return confirm(message); }
	                ///alert(rt);
	            }
	        return rt;
	    }

	    function SelectAll(sa) {
	        ///全选/全消
	        var objCheckBox;
	        for (var i = 0; i < form1.length; i++) {
	            if (form1.elements[i].type == "checkbox") {
	                objCheckBox = form1.elements[i];
	                objCheckBox.checked = sa;
	            }
	        }
	    }

	    function SetApplicationButton() {

	        if ("<%= base.Administrator.AdminTypeId %>" != "1" ) {
	            var selValue = document.getElementById("<%= this.ddlStates.ClientID %>").options[document.getElementById("<%= this.ddlStates.ClientID %>").selectedIndex].value;
	            if (selValue != "4") {

	                if ("<%= base.Administrator.CompanyLevelId %>" != "1" && "<%= base.Administrator.CompanyLevelId %>" != "0") {
	                    document.getElementById("<%= this.ibtnOpenCardCompany.ClientID %>").style.display = "none";
	                }

	            } else {

	                if ("<%= base.Administrator.CompanyLevelId %>" != "1" && "<%= base.Administrator.CompanyLevelId %>" != "0") {
	                    document.getElementById("<%= this.ibtnOpenCardCompany.ClientID %>").style.display = "block";
	                }
	            }
	        }
        
        }

</script>

</head>
<body class="body">

    <form id="form1" runat="server">

            <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <ContentTemplate>
                     <table width="98%" border="0" cellpadding="0" cellspacing="4" style="border-bottom:0;">
    <tr>
      <td width="2%"><img height="22" alt="SEARCH" src="../images/icon_search.gif" width="26" border="0" /></td>
          <td width="4%" style="text-align:right;">行数</td>
            <td >
            <asp:DropDownList ID="ddlRowCount" runat="server">
            <asp:ListItem Text="50" Value="50"></asp:ListItem>
             <asp:ListItem Text="100" Value="100"></asp:ListItem>
               <asp:ListItem Text="200" Value="200"></asp:ListItem>
               <asp:ListItem Text="500" Value="500"></asp:ListItem>
            </asp:DropDownList>
            </td>
      <td width="4%" style="text-align:right;">卡号</td>
      <td width="12%"><input size="12" name="cardcodeFrom" id="cardcodeFrom" 
              runat="server" />
              </td>
              <td width="16%">
               至 
          <input size="12" name="cardcodeTo" id="cardcodeTo" 
              runat="server" /></td>
              <td width="20%">
              <asp:DropDownList ID="ddlAgentType" runat="server" AutoPostBack="True" 
                      onselectedindexchanged="ddlAgentType_SelectedIndexChanged" >
                 <asp:ListItem Value="0" Text="自身卡券"></asp:ListItem>
                 <asp:ListItem Value="1" Text="一级代理卡券"></asp:ListItem>
                 <asp:ListItem Value="2" Text="二级代理卡券"></asp:ListItem>
                 <asp:ListItem Value="3" Text="三级代理卡券"></asp:ListItem>
              </asp:DropDownList>
              
              </td>
                        <td width="8%">                
          <asp:DropDownList ID="ddlProvence" runat="server"  AutoPostBack="true"
              onselectedindexchanged="ddlProvence_SelectedIndexChanged">
          </asp:DropDownList>      
      </td>
         <td id="tdLevelName" runat="server" width="12%" style="text-align:right;">代理商家级别</td>
           <td id="tdLevelValue" runat="server" width="12%">
              <asp:DropDownList ID="ddlLevel" runat="server"    AutoPostBack="true"
                   onselectedindexchanged="ddlLevel_SelectedIndexChanged">
              </asp:DropDownList>
            </td>
           <td id="tdCompany" runat="server" width="8%" style="text-align:right;">代理商家</td>
           <td id="tdCompanySelect" runat="server" width="24%">
              <asp:DropDownList ID="ddlCompany0" runat="server">
              </asp:DropDownList>
            </td>
      </tr>
      </table>
        
        </ContentTemplate>
            <table width="100%" border="0" cellpadding="0" cellspacing="4"  class="img">
      <tr>

      <td  align="left">
          <asp:DropDownList ID="ddlStates" runat="server"  onchange="SetApplicationButton()">
          </asp:DropDownList>
      </td>
      <td style="text-align:right; display:none;">卡大类</td>
      <td style="display:none;">
         <asp:DropDownList ID="ddlProfessionAreaType" runat="server" 
             ></asp:DropDownList>
      </td>
     <td style="text-align:right;">     
         卡类别</td>
         <td>        
              <asp:DropDownList ID="ddlCardType" runat="server">
              </asp:DropDownList>       
         </td>
            <td style="text-align:right;">发行方式</td>
       <td  width="12%">
       
       <asp:DropDownList ID="ddlPublishWay" runat="server">
       
       <asp:ListItem Text="卡券" Value="卡券" ></asp:ListItem>
         <asp:ListItem Text="电子券" Value="电子券" ></asp:ListItem>
       </asp:DropDownList>
                                                                   
        </td>
      
      <td  style="text-align:right;">日期</td>
      <td width="20%">
             <input id="dateFrom"  name="dateFrom" runat="server" type="text" size="6" onfocus="new WdatePicker(this,'%Y-%M-%D',true,'default')"  onpaste="return false" style="ime-mode: disabled"  /> 
      至     
      <input id="dateTo"  name="dateTo" runat="server" type="text"  size="6" onfocus="new WdatePicker(this,'%Y-%M-%D',true,'default')"  onpaste="return false" style="ime-mode: disabled"  />
   
      </td>
      <td style="text-align:right">
        <asp:ImageButton ID="ibtnSearch" ImageUrl="../images/button04.gif" runat="server"    OnClick="ibtnSearch_Click" style="height: 20px" />
        &nbsp; 
        &nbsp;<asp:ImageButton ID="ibtnStoreOut"  style="display:none;" ImageUrl="../images/btnGetCard.gif" runat="server" OnClick="ibtnStoreOut_Click" />
        &nbsp;<asp:ImageButton ID="ibtnExport" ImageUrl="../images/btnExport.gif" runat="server" OnClick="ibtnExport_Click" />    
        &nbsp;</td>
    </tr>
  </table>
     <div class="maincontent">
  <asp:GridView ID="GridView1"  runat="server" width="100%" CellPadding="4"  DataKeyNames="cardid" AutoGenerateColumns="False" 
        AllowPaging="True" pagesize="50"    OnRowDataBound="GridView1_RowDataBound"  ShowFooter="false" EmptyDataText="没有数据记录！！" AllowSorting="True"  OnSorting="GridView1_Sorting" onrowcommand="GridView1_RowCommand" 
        onselectedindexchanged="GridView1_SelectedIndexChanged">
 
  
       
        <Columns>
            <asp:TemplateField ShowHeader="False" HeaderText="选择">
             <ItemStyle Width="30px" Wrap="False" />
             <HeaderTemplate>
                 <asp:CheckBox ID="CheckBox1" runat="server"></asp:CheckBox>
             </HeaderTemplate>
             <ItemTemplate>
                 <asp:CheckBox ID="CheckBox1" runat="server"></asp:CheckBox>
             </ItemTemplate>
            </asp:TemplateField>
        <asp:BoundField HeaderText="卡 号" DataField="cardcode" sortexpression="cardcode" />
        <asp:BoundField HeaderText="礼品卡类别" DataField="CardTypeName" />
        <asp:BoundField HeaderText="发行方式" DataField="publishWay"  />
        <asp:BoundField HeaderText="面值" DataField="cardPrice"  />
        <asp:BoundField HeaderText="有效日期" DataField="exptime" />  
        <asp:BoundField HeaderText="商家" DataField="companyName"  />
        <asp:BoundField HeaderText="状 态" DataField="statesName" />   
        <asp:BoundField HeaderText="开卡日期" DataField="openTime" Visible="true" sortexpression="openTime" DataFormatString="{0:yyyy-MM-dd}" />
        <asp:BoundField HeaderText="领用日期" DataField="AreadyPublishNoOpenTime" Visible="true" sortexpression="AreadyPublishNoOpenTime" DataFormatString="{0:yyyy-MM-dd}" />
          <asp:BoundField HeaderText="申请开卡日期" DataField="ApplicationOpenTime" Visible="true" sortexpression="ApplicationOpenTime" DataFormatString="{0:yyyy-MM-dd}" />
        <asp:TemplateField ShowHeader="False" HeaderText="操作">
        <ItemStyle Width="120px" />
             <ItemTemplate>
             <div style="float:left;">
             <div style="float:left;">
               <asp:LinkButton ID="lbtnOpen" CommandName="open" OnClientClick="return confirm('确定要激活吗?');" CommandArgument='<%# Container.DataItemIndex %>' runat="server" Text="激活"></asp:LinkButton>
                 &nbsp;
                 </div>
                 <div style="float:left;">
             <!--  <a style='cursor:hand; display:<%= isDisplayGMS%>'  onclick="javascript:window.open('SendGSM.aspx?cardid=<%# Eval("cardid") %>','window','Width=400px,Height=400px')">
                    短信
               </a>-->
               </div>
               </div>
             </ItemTemplate>
        </asp:TemplateField>
           <asp:TemplateField ShowHeader="False" HeaderText="备注">
        <ItemStyle Width="80px" />
             <ItemTemplate>
               <a title="<%# Eval("remark")  %>"><%#  Eval("remark") != null && Eval("remark").ToString().Length > 5  ? Eval("remark").ToString().Substring(0,5) + "..." : "" %></a>
             </ItemTemplate>
        </asp:TemplateField>
        </Columns>
             <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />             
             <PagerStyle BackColor="White" ForeColor="#333333" HorizontalAlign="Center" Font-Bold="True"  />
             <HeaderStyle  Font-Bold="True" ForeColor="Black" HorizontalAlign="Center" />
             <AlternatingRowStyle BackColor="#f0f6fa" />
                   <RowStyle BackColor="#FFFFFF" />
             <PagerSettings Visible="False" />
        </asp:GridView>
           </div>

         <table width="100%" border="0" cellspacing="0"  cellpadding="0">
       <tr>  

         <td height="25" align="left"  colspan="7">
         <asp:Label ID="LblRecordCount" runat="server"></asp:Label>
            <asp:Label ID="LblCurrentIndex" runat="server"></asp:Label>
            <asp:Label ID="LblPageCount" runat="server"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <asp:LinkButton ID="btnFirst" CommandArgument="first" OnClick="PagerButtonClick" runat="server">首 页</asp:LinkButton> 
            <asp:LinkButton ID="btnPrev" CommandArgument="prev" OnClick="PagerButtonClick" runat="server">上一页</asp:LinkButton> 
            <asp:LinkButton ID="btnNext" CommandArgument="next" OnClick="PagerButtonClick" runat="server">下一页</asp:LinkButton> 
            <asp:LinkButton ID="btnLast" CommandArgument="last" OnClick="PagerButtonClick" runat="server">尾 页</asp:LinkButton> 
             跳转到第<asp:DropDownList ID="ddlCurrentPage" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> </asp:DropDownList>页&nbsp;
         </td>
       </tr>
       <tr>  
       
         <td id="tdOpenCardCompanyMessage" runat="server" height="25" align="left"  style="color:Red;" colspan="6">
             </td>
       </tr>
  
          <tr id="trCompanyOperate" runat="server">
       <td  style="width:100px;">
             <asp:ImageButton ID="ibtnOpenCardCompany" style="display:block;"  OnClientClick="return CheckSelectUpdate(true,'update','如果您有预付款，将直接激活选中的礼品卡，并扣除相应的预付款，确定要激活选中的礼品卡吗？');" ImageUrl="/admin/images/btnOpenCardCompany.gif" runat="server" OnClick="ibtnOpenCard_Click" />
             </td>
        
            <td width="1%">                
                &nbsp;</td>
         <td id="td1" runat="server" width="48%" colspan="2" style="text-align:right;">   
         

          <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
                      
          <asp:DropDownList ID="ddlProvence1" runat="server"  AutoPostBack="true" 
                 onselectedindexchanged="ddlProvence1_SelectedIndexChanged">
          </asp:DropDownList>      
            
              <asp:DropDownList ID="ddlLevel1" runat="server"    AutoPostBack="true" 
                   onselectedindexchanged="ddlLevel1_SelectedIndexChanged"> </asp:DropDownList>

              <asp:DropDownList ID="ddlCompany1" runat="server">
              </asp:DropDownList>

                </ContentTemplate>
    </asp:UpdatePanel>
    </td>
    <td>

        <asp:ImageButton ID="ibtnUpdateCompany"  OnClientClick="return CheckSelectUpdate(true,'update','确定要更新商家吗？');" ImageUrl="../images/btnUpdateCompany.gif" runat="server" OnClick="ibtnUpdateCompany_Click" />
           </td>
           <td id="tdStates1" runat="server" height="25" align="right"  style="text-align:left; width:300px;"><span id="spanStates1" runat="server">卡片状态</span>
          <asp:DropDownList ID="ddlStates1" runat="server">
          </asp:DropDownList>

      <asp:ImageButton ID="ibtnOpenCard1"  OnClientClick="return CheckSelectUpdate(true,'update','确定要批量更新选中的礼品卡状态吗？');" ImageUrl="../images/btnUpdateStatesAll.gif" runat="server" OnClick="ibtnOpenCard0_Click" />
      
              </td>            
       </tr>
          <tr>
      <td height="40" align="left" id="tdExport" runat="server"  colspan="6">
          <asp:FileUpload ID="FileUpload1" runat="server" Width="260px" />

            <asp:ImageButton ID="ibtnInport"   ImageUrl="../images/btnInport.gif" runat="server" OnClick="ibtnInport_Click" />
              </td>   
       </tr>
       <tr><td colspan="6">&nbsp;</td></tr>
    </table>
  
 
    </form>
</body>
</html>
